<template>
  <div class="row">
    <el-main class="ctxt" v-for="(item, index) in paperid" :key="index">
      <el-container>
        <el-header height="30px" class="cl-top">
          <i v-if="item.good">
            <img
              class="typeImg"
              draggable="false"
              src="https://cdn.hterobot.com/vue/public/forum/jian.png"
            >
          </i>
          <i v-if="item.lock">
            <img
              class="typeImg"
              draggable="false"
              src="https://cdn.hterobot.com/vue/public/forum/jian.png"
            >
          </i>
          <i v-if="item.top">
            <img
              class="typeImg"
              draggable="false"
              src="https://cdn.hterobot.com/vue/public/forum/re.png"
            >
          </i>
          <h4>
            <router-link class="route" :to="{name: 'detail', params:{id: item.ID}}">{{item.title}}</router-link>
          </h4>
        </el-header>
        <el-main class="text">{{item.txt}}</el-main>
        <el-footer height="30px" class="footer row text-center">
          <router-link :to="{name: 'user', params:{uid: item.uid}}" class="col-5 text-left" >
            <img
              class="authorImg"
              draggable="false"
              :src="item.headimg?item.headimg:'/public/static/imgs/forum/touxiang.png'"
            >
            <span>{{item.username}}</span>
          </router-link>
          <div class="col">
            <div class="row">
              <div class="col">
                <span v-text="times(item.createtime)"></span> 天前
              </div>
              <div class="col">
                <i class="icon-xinxi icon iconfont"></i>
                {{ item.reply_count }}
              </div>
              <div class="col">
                <i class="el-icon-view"></i>
                {{ item.click_count }}
              </div>
              <div class="col">
                <i class="icon-xinaixin- icon iconfont text-success"></i>
                {{ item.collect_count }}
              </div>
            </div>
          </div>
        </el-footer>
      </el-container>
    </el-main>
    <br>
    <br>
    <br>
    <el-pagination
      v-show="gettopiccount>25"
      @current-change="handleCurrentChange"
      small
      :page-size="25"
      layout="prev, pager, next"
      :total="gettopiccount"
    ></el-pagination>
  </div>
</template>

<script>
import {
  asynccreatetopiccollect,
} from "../../../plugins/api.js";
import { mapGetters } from "vuex";
export default {
    data() {
        return {
            paperid: {},
        };
    },
     async created() {
    this.start();
  },
   watch: {
    $route() {
      this.start();
    }
  },
  computed: mapGetters(["gettopiccount","getuser"]),
    methods:{
       handleCurrentChange(v) {
      this.$router.push({
        name: "forun",
        query: {
          limit: 25,
          offset: 25 * (v - 1)
        }
      });
    },
      async start() {
      this.paperid = await asynccreatetopiccollect();
      console.log(this.paperid)
    },
    }
};
</script>

<style lang='scss' scoped>

</style>